﻿#*******************************************************************************
#	RR, a python roguelike
#   Copyright (C) 2012  Vivien Bihl
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#*******************************************************************************

from rrDefine import *
from rrDice import *
from rrTile import *
from rrRect import *
from rrObject import *
from rrCursor import *
from rrMap import *
from rrFunc import *
from rrHud import *

#*******************************************************************************
#
#	MAIN
#
#*******************************************************************************

if __name__ == '__main__':

	#curses initialization
	stdscr = initscr()
	noecho()
	cbreak()
	curs_set(0)
	keypad(stdscr, True)
	start_color()

	#game initialization
	player = Player("Vivien")
	objects = [player]
	turn_elapsed=0
	action=NONE
	map=Map()
	map.place_objects(player,objects)
	#first iteration before loop
	blit_screen(player, objects, map.map)
	draw_hud(player,turn_elapsed,1)

	
	#main game loop
	while action!=QUIT:
		
		if action==TURN_TAKEN:
			turn_elapsed+=1
			player.hunger-=1
			player.level_up()
		
		#draw everything on screen
		blit_screen(player, objects, map.map)
		draw_hud(player,turn_elapsed,1)
		check_multiple_item(player, objects)
		refresh()
		
		action=handle_key(player, objects, map.map)
	#curses end	
	endwin()
	